package com.my.mr.NumSort;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.CombineTextInputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class NumSortDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        final Configuration configuration = new Configuration();
        final Job job = Job.getInstance(configuration, "NumSort");
        job.setJarByClass(NumSortDriver.class);
        job.setMapperClass(NumSortMapper.class);
        job.setReducerClass(NumSortReduce.class);

        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);
        //默认就是1所以不需要设置
        //job.setNumReduceTasks(1);
        FileInputFormat.setInputPaths(job, new Path("C:\\Users\\shencaobo\\IdeaProjects\\my-project\\正式阶段第一阶段第一模块\\code\\work"));
        FileOutputFormat.setOutputPath(job, new Path("C:\\Users\\shencaobo\\IdeaProjects\\my-project\\正式阶段第一阶段第一模块\\code\\work\\out"));

        final boolean flag = job.waitForCompletion(true);
        //jvm 退出
        System.exit(flag ? 0 : 1);
    }
}
